<!DOCTYPE html>
<html ng-app="e-app">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<title>双千养老服务</title>

		<script type="text/javascript">
			 //<![CDATA[
			try {
				if (!window.CloudFlare) {
					var CloudFlare = [{
						verbose: 0,
						p: 1419364062,
						byc: 0,
						owlid: "cf",
						bag2: 1,
						mirage2: 0,
						oracle: 0,
						paths: {
							cloudflare: "/cdn-cgi/nexp/dok2v=1613a3a185/"
						},
						atok: "1fca8a26fb9678bbb4b5c54c34e227b9",
						petok: "da6017be29f01e13c800a4827955e25c0369462e-1420553962-1800",
						zone: "adbee.technology",
						rocket: "0",
						apps: {
							"ga_key": {
								"ua": "UA-49262924-2",
								"ga_bs": "2"
							}
						}
					}];
					! function(a, b) {
						a = document.createElement("script"), b = document.getElementsByTagName("script")[0], a.async = !0, a.src = "//ajax.cloudflare.com/cdn-cgi/nexp/dok2v=919620257c/cloudflare.min.js", b.parentNode.insertBefore(a, b)
					}()
				}
			} catch (e) {};
			 //]]>
		</script>
		<link rel="stylesheet" type="text/css" href="../../default/css/bootstrap/bootstrap.min.css" />

		<script src="../../default/js/demo-rtl.js"></script>

		<link rel="stylesheet" type="text/css" href="../../default/css/libs/font-awesome.css" />
		<link rel="stylesheet" type="text/css" href="../../default/css/libs/nanoscroller.css" />

		<link rel="stylesheet" type="text/css" href="../../default/css/compiled/theme_styles.css" />

		<!--<link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>-->

		<link type="image/x-icon" href="favicon.png" rel="shortcut icon" />
		<!--[if lt IE 9]>
		<script src="../../default/js/html5shiv.js"></script>
		<script src="../../default/js/respond.min.js"></script>
	<![endif]-->


        <script src="../../public/angular/angular.min.js"></script>
        <script src="../../public/angular/angular-route.min.js"></script>
        <script src="../../public/js/angular-baas.js"></script>
        <script src="../../public/js/config.js"></script>

        <script src="../js/app.js"></script>


		<script type="text/javascript">
			 /* <![CDATA[ */
			var _gaq = _gaq || [];
			_gaq.push(['_setAccount', 'UA-49262924-2']);
			_gaq.push(['_trackPageview']);
			(function() {
				var ga = document.createElement('script');
				ga.type = 'text/javascript';
				ga.async = true;
				//ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
				var s = document.getElementsByTagName('script')[0];
				s.parentNode.insertBefore(ga, s);
			})();
			(function(b) {
				(function(a) {
					"__CF" in b && "DJS" in b.__CF ? b.__CF.DJS.push(a) : "addEventListener" in b ? b.addEventListener("load", a, !1) : b.attachEvent("onload", a)
				})(function() {
					"FB" in b && "Event" in FB && "subscribe" in FB.Event && (FB.Event.subscribe("edge.create", function(a) {
						_gaq.push(["_trackSocial", "facebook", "like", a])
					}), FB.Event.subscribe("edge.remove", function(a) {
						_gaq.push(["_trackSocial", "facebook", "unlike", a])
					}), FB.Event.subscribe("message.send", function(a) {
						_gaq.push(["_trackSocial", "facebook", "send", a])
					}));
					"twttr" in b && "events" in twttr && "bind" in twttr.events && twttr.events.bind("tweet", function(a) {
						if (a) {
							var b;
							if (a.target && a.target.nodeName == "IFRAME") a: {
								if (a = a.target.src) {
									a = a.split("#")[0].match(/[^?=&]+=([^&]*)?/g);
									b = 0;
									for (var c; c = a[b]; ++b)
										if (c.indexOf("url") === 0) {
											b = unescape(c.split("=")[1]);
											break a
										}
								}
								b = void 0
							}
							_gaq.push(["_trackSocial", "twitter", "tweet", b])
						}
					})
				})
			})(window);
			/* ]]> */
		</script>
	</head>

	<body id="login-page" ng-controller="loginController" onkeydown="listenEnter();">
		<div class="container">
			<div class="row">
				<div class="col-xs-12">
					<div id="login-box">
						<div id="login-box-holder">
							<div class="row">
								<div class="col-xs-12">
									<header id="login-header">
										<div id="login-logo">
											<img src="../img/logo.png" alt="" />
										</div>
									</header>
									<div id="login-box-inner">
										<form role="form" action="index.html">
											<div class="input-group">
												<span class="input-group-addon"><i class="fa fa-user"></i></span>
												<input id="account" class="form-control" type="text" placeholder="请输入用户名">
											</div>
											<div class="input-group">
												<span class="input-group-addon"><i class="fa fa-key"></i></span>
												<input id="password" type="password" class="form-control" placeholder="请输入密码">
											</div>
											<!--<div id="remember-me-wrapper">-->
												<!--<div class="row">-->
													<!--<div class="col-xs-6">-->
														<!--<div class="checkbox-nice">-->
															<!--<input type="checkbox" id="remember-me" checked="checked" />-->
															<!--<label for="remember-me">-->
																<!--记住我-->
															<!--</label>-->
														<!--</div>-->
													<!--</div>-->
													<!--<a href="forgot-password.html" id="login-forget-link" class="col-xs-6">-->
<!--Forgot password?-->
<!--</a>-->
												<!--</div>-->
											<!--</div>-->
											<div class="row">
												<div class="col-xs-12">
													<a id="login"  ng-click="login()" class="btn btn-success col-xs-12">登录</a>
												</div>
											</div>
											
										</form>
									</div>
								</div>
							</div>
						</div>
						<!--<div id="login-box-footer">-->
							<!--<div class="row">-->
								<!--<div class="col-xs-12">-->
									<!--还没有帐号?-->
									<!--<a href="registration.html">-->
 <!--现在注册-->
<!--</a>-->
								<!--</div>-->
							<!--</div>-->
						<!--</div>-->
					</div>
				</div>
			</div>
		</div>
		

		<script src="../../default/js/demo-skin-changer.js"></script>
		<script src="../../default/js/jquery.js"></script>
		<script src="../../default/js/bootstrap.js"></script>
		<script src="../../default/js/jquery.nanoscroller.min.js"></script>
		<script src="../../default/js/demo.js"></script>

		<script src="../../default/js/scripts.js"></script>
		<script src="../../public/js/jquery-baas.js"></script>


		<script>

app.controller('loginController',function($scope, $http ) {

    $scope.login = function(){
        var data = {
            'account'  : $('#account').val(),
		    'password' : $('#password').val(),
            'with_ts'  : 1
        };
        baas_yl.call({
            'http': $http,
            'method': 'post',
            'data':data,
            'uri': 'manager/manager/login',
			
            'success': function(d) {
                if(d.status == 1){
                    sessionStorage.setItem( "ts", d.ts );
                    console.log(123);
                     $scope.checkLogin();
                }else{
                    alert("账户或密码错误");
                }
            }
        });
    };

    $scope.checkLogin = function(){
        console.log(789);
        baas_yl.call({
            'http': $http,
            'method': 'get',
            'uri': 'manager/manager/checkLogin',

            'success': function(d) {
            	if(d.login!='logged'){
		             location.href='/login.html';
		        }else{
		        	var rules=d.type_code;
                    console.log(d);
		        	if(rules=="admin"){
                        location.href='../index.html#/home';
		        	} else if (rules == 'company') {
                        location.href = '../index.html#/company/home';
					} else if(rules=="allTest"){
                        location.href='../index.html#/callCenter/index';
		        	}else{
		        		location.href='../index.html#/card/index';
		        	}
		        }
            }
        });
    };

//    $scope.checkLogin();

});
		</script>
		<script language="javascript">
			function listenEnter() {
				if(window.event.keyCode == 13){
					if (document.getElementById("login") != null){
						document.getElementById("login").click();
					}
				}
			}
		</script>
	</body>

</html>